package com.pj.wisdomlogistics.ui.fragment;

import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.pj.wisdomlogistics.MyApplication;
import com.pj.wisdomlogistics.R;
import com.pj.wisdomlogistics.cons.Cons;
import com.pj.wisdomlogistics.other.EventCenter;
import com.pj.wisdomlogistics.ui.activity.BusinessCheckActivity;
import com.pj.wisdomlogistics.ui.activity.ChooseTakeoutActivity;
import com.pj.wisdomlogistics.ui.activity.MenuEditorActivity;
import com.pj.wisdomlogistics.ui.activity.MyApplyActivity;
import com.pj.wisdomlogistics.ui.activity.MyTransactActivity;
import com.pj.wisdomlogistics.ui.activity.RepairActivity;
import com.pj.wisdomlogistics.ui.view.BadgerView;

import butterknife.BindView;
import butterknife.OnClick;


public class ServiceAccountFragment extends BaseFragment {
    @BindView(R.id.view_badger)
    BadgerView mBadgerView;
    @BindView(R.id.tv_service_wddb)
    TextView mTvDb;
    @BindView(R.id.ll_main2)
    LinearLayout mLayoutMain2;

    @Override
    protected void initView() {
        if(MyApplication.isGzh){
            mTvDb.setText("业务查看");
        }

        for (int i = 0; i < MyApplication.user.getRoleId().size(); i++) {
            if(MyApplication.user.getRoleId().get(i).equals("402848d05f562a0d015f5b46973d0004")
                || MyApplication.user.getRoleId().get(i).equals("402848d05f8edf68015f900ff8da0000")){
                mLayoutMain2.setVisibility(View.VISIBLE);
            }
        }

    }

    @Override
    protected void initData() {

    }

    @Override
    protected void onFirstUserVisible() {

    }

    @Override
    protected void onUserVisible() {

    }

    @Override
    protected void onUserInvisible() {

    }

    @Override
    public int getContentView() {
        return R.layout.fragment_service_account;
    }

    @Override
    protected boolean isApplyEventBus() {
        return true;
    }

    @Override
    protected boolean isApplyButterKnife() {
        return true;
    }

    @Override
    protected void onEventCome(EventCenter eventCenter) {
        if(eventCenter.getEventCode() == Cons.Badger.BADGER_SERVICE){
            mBadgerView.setMessageCount((Integer) eventCenter.getData());
        }
    }

    @OnClick({R.id.tv_service_apply, R.id.tv_service_wmdc, R.id.tv_service_whbx,
            R.id.tv_service_wddb , R.id.tv_service_menu})
    public void onViewClicked(View view) {
        //服务帐号及所有管理帐号
        switch (view.getId()) {
            case R.id.tv_service_apply:
                //我的申请
                startActivity(MyApplyActivity.class);
                break;
            case R.id.tv_service_wmdc:
                //外卖点餐
                startActivity(ChooseTakeoutActivity.class);
                break;
            case R.id.tv_service_whbx:
                //维护保修
                startActivity(RepairActivity.class);
                break;
            case R.id.tv_service_wddb:
                if(MyApplication.isGzh){
                    startActivity(BusinessCheckActivity.class);
                }else{
                    startActivity(MyTransactActivity.class);
                }
                //我的待办
                break;
            case R.id.tv_service_menu:
                startActivity(MenuEditorActivity.class);
                break;
        }
    }
}
